package xyz.liuyuhe.StudySpring.ch7.aop;

import java.lang.reflect.Method;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

public class DBQueryInterceptor implements MethodInterceptor{
    private Object target;
    
    public DBQueryInterceptor(Object target){
        this.target = target;
    }
    
    public Object intercept(Object arg0, 
            Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
        System.out.println("Query ID:" + arg2[0]);
        Object result = arg3.invoke(target, arg2);
        return result;
    }

}
